package com.gxwzxy.medic.service.Impl;

import java.util.List;

import com.gxwzxy.medic.dao.ChronicdisDao;
import com.gxwzxy.medic.dao.Impl.ChronicdisDaoImpl;
import com.gxwzxy.medic.entity.Chronicdis;
import com.gxwzxy.medic.service.ChronicdisService;
import com.gxwzxy.medic.until.PageBean;

public class ChronicdisServiceImpl implements ChronicdisService {

	/**
	 * 慢病分页
	 */
	@Override
	public void pageChronicdis(PageBean<Chronicdis> pu) {
		ChronicdisDao cd = new ChronicdisDaoImpl();
		//查询数据库表获取记录总数
		int totalCount = cd.findChronicdisSize();
		//使用记录总数计算PageBean中其他属性：totalPageCount(总页数)，numbers(页数集合)
		pu.setTotalCount(totalCount);
		//调用Dao层获取指定页数的学生数据，并放入PageBean的list属性
		int start = pu.getStartRow();
		int size = pu.getSize();
		List<Chronicdis> lc = cd.findChronicdisIndex(start,size);
		pu.setList(lc);
	}

	/**
	 * 保存慢病
	 */
	@Override
	public boolean saveIll(Chronicdis c) {
		ChronicdisDao cd = new ChronicdisDaoImpl();
		return cd.saveIll(c);
	}

	/**
	 * 根据illCode修改慢病
	 */
	@Override
	public boolean updateChr(Chronicdis c) {
		ChronicdisDao cd = new ChronicdisDaoImpl();
		return cd.updateChr(c);
	}

	/**
	 * 根据illCode删除慢病
	 */
	@Override
	public boolean deleteIll(String illCode) {
		ChronicdisDao cd = new ChronicdisDaoImpl();
		return cd.deleteIll(illCode);
	}

}
